//
//  VOCMutableWordList.m
//  iVoc
//
//  Created by Wallace Wu on 09-4-20.
//  Copyright 2009 Sonic Solutions. All rights reserved.
//

#import "VOCMutableWordList.h"

VOCMutableWordList *favorite = nil;

@implementation VOCMutableWordList

+(VOCMutableWordList*)favoriteList
{
    if(!favorite)
    {
        favorite = [[NSKeyedUnarchiver unarchiveObjectWithFile:VOC_DEFAULT_FAVORITE_LIST] retain];
        if(!favorite)
        {
            favorite = [[VOCMutableWordList alloc] initWithName:NSLocalizedString(@"MY_FAVORITE",nil)];
        }
    }
    return favorite;
}

-(id)initWithName:(NSString*)aname;
{
    self = [super init];
    if(self)
    {
        self.name = aname;
        self.data = [NSMutableArray array];
    }
    
    return self;
}


-(id)initWithCoder:(NSCoder*)aCoder
{
    // in this initialization method, all arrays are mutable which are not in super-class
    self = [super initWithCoder:aCoder];
    if(self)
    {
        if(![self.data isMemberOfClass:[NSMutableArray class]])
        {
            self.data = [[self.data mutableCopy] autorelease];
        }
        
    }
    
    return self;
}

-(void)addWord:(VOCWordData*)aWord
{
    [(NSMutableArray*)self.data addObject:aWord];
}

-(void)removeWord:(VOCWordData*)aWord
{
    [(NSMutableArray*)self.data removeObject:aWord];
}


@end
